package com.fs.generator.db.metadata;

import java.util.LinkedList;
import java.util.List;

import lombok.Data;

@Data
public class TableMetadata {

	/** 表名称 */
	private String name;
	private String comment;
	/** 列信息 */
	private List<ColumnMetadata> columnMetadatas = new LinkedList<ColumnMetadata>();

	public int indexOfPropertyName(String propertyName) {
		for (int j = 0; j < columnMetadatas.size(); j++) {
			ColumnMetadata columnMetadata = columnMetadatas.get(j);
			if (columnMetadata.getPropertyName().equalsIgnoreCase(propertyName)) {
				return j;
			}
		}
		return -1;
	}

	public int indexOfColumnName(String columnName) {
		for (int j = 0; j < columnMetadatas.size(); j++) {
			ColumnMetadata columnMetadata = columnMetadatas.get(j);
			if (columnMetadata.getName().equalsIgnoreCase(columnName)) {
				return j;
			}
		}
		return -1;
	}

}
